/**
 * acelab
 * @Author Ace.c
 * @Create 2016-11-29 11:25
 */
class acelab {

    static stage: egret.Stage;

    static get width() {
        return this.stage ? this.stage.stageWidth : 0;
    }

    static get height() {
        return this.stage ? this.stage.stageHeight : 0;
    }

    static init(stage) {
        this.stage = stage;
        LayerManager.i.init();
    }

    static contains(display): boolean {
        return this.stage && this.stage.contains(display);
    }

    static addChild(display) {
        this.stage && this.stage.addChild(display);
    }

    static removeChild(display) {
        this.contains(display) && this.stage.removeChild(display);
    }

    //获得平台类型 如 微信、qqzone、qq、微博、校内、facebook
    static platformType(): string {
        let ua = window.navigator.userAgent.toLowerCase();

        if (("" + ua.match(/micromessenger/i)) == "micromessenger") {
            return "micromessenger";
        }
        else if (("" + ua.match(/qzone/i)) == "qzone") {
            return "qzone";
        }
        else if (("" + ua.match(/weibo/i)) == "weibo") {
            return "weibo";
        }
        else if (("" + ua.match(/qq/i)) == "qq") {
            return "qq";
        }
        else if (("" + ua.match(/renren/i)) == "renren") {
            return "renren";
        }
        else if (("" + ua.match(/txmicroblog/i)) == "txmicroblog") {
            return "txmicroblog";
        }
        else if (("" + ua.match(/douban/i)) == "douban") {
            return "douban";
        }
        else {
            return "other";
        }
    }

    //获得浏览器类型 pc android ios -- 可扩展为其他 如 微信、qqzone、qq、微博、校内、facebook
    static systemType(): string {
        let ua = window.navigator.userAgent.toLowerCase();

        if (("" + ua.match(/windows nt/i)) == "windows nt") {
            return "windows";
        }
        else if (("" + ua.match(/iphone/i)) == "iphone") {
            return "ios";
        }
        else if (("" + ua.match(/android/i)) == "android") {
            return "android";
        }
        else if (("" + ua.match(/ipad/i)) == "ipad") {
            return "ipad";
        }
        else if (("" + ua.match(/linux/i)) == "linux") {
            return "linux";
        }
        else if (("" + ua.match(/mac/i)) == "mac") {
            return "mac";
        }
        else if (("" + ua.match(/ucbrower/i)) == "ucbrower") {
            return "ucbrower";
        }
        else {
            console.log("未知系统类型");
        }
    }
}